﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Microsoft.Practices.EnterpriseLibrary.Common;
using System.Configuration;
using Insifo.BE;

namespace Insifo.DL.Gen
{
    public class DLCuentaContable
    {
        #region  Members
        /// <summary>
        /// Método obtiene cuentas contables
        /// </summary>
        /// <returns>Devuelve un DataSet</returns>
        /// 
        public DataSet Listar(string pstrCentroCosto, string pstrIdioma)
        {
            DataSet ds = new DataSet();
            SqlDatabase sqlDB = new SqlDatabase(CadenaConexion.Obtener());
            DbCommand dbCmd = sqlDB.GetStoredProcCommand("Usp_CIDE_SPRING_CuentaContable");            
            try
            {
                dbCmd.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeout"]);
                sqlDB.AddInParameter(dbCmd, "@as_centrocosto", DbType.String, pstrCentroCosto);
                sqlDB.AddInParameter(dbCmd, "@as_idioma", DbType.String, pstrIdioma);
                ds = sqlDB.ExecuteDataSet(dbCmd);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {               
                //if (dbCmd.Connection.State == ConnectionState.Open)
                    //dbCmd.Connection.Close();
                dbCmd.Dispose();
            }
            return ds;
        }

        #endregion  Members
    }
}
